﻿using Microsoft.Practices.Unity;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using TestByWire.Test.Fakes;

namespace TestByWire.Test
{
    [TestClass]
    public class AutoInjectionBehaviorIntegrationTest
    {
        private IUnityContainer _container;

        [TestInitialize]
        public void PerTestSetup()
        {
            _container = new UnityContainer();
            _container.AddNewExtension<AutoInjectionBehavior<Computer>>();
            Recorder.Reset(_container);
        }

        [TestMethod]
        public void MustBeAbleToResolveAutoInjectedType()
        {
            var computer = _container.Resolve<Computer>();

            Assert.IsNotNull(computer.Calculator);
        }

        [TestMethod]
        public void MustBeAbleToResolveAbstractClass()
        {
            var abstractCalculator = _container.Resolve<AbstractCalculator>();

            Assert.IsNotNull(abstractCalculator);
        }

        [TestMethod]
        public void MustBeAbleToResolveInterface()
        {
            var simpleInterface = _container.Resolve<IComplexTestClassReturn>();

            Assert.IsNotNull(simpleInterface);
        }

        [TestMethod]
        public void MustBeAbleToResolveInternalClass()
        {
            var internalClass = _container.Resolve<InternalClass>();

            Assert.IsNotNull(internalClass);
        }
    }
}
